package com.magalindo8;

import android.os.Handler;
import android.os.Message;

import com.google.android.gms.ads.AdView;
import com.google.android.gms.ads.InterstitialAd;
import com.ma.logica.IReqHandler;

public class RequestHandler implements IReqHandler{

	protected AdView adV;
	protected static InterstitialAd interstitial;
	protected int adHeight = 10;

	private final static int SHOW_ADS = 1;
	private final static int HIDE_ADS = 0;
	private final static int SHOW_FULLADS = 3;
	private final static int HIDE_FULLADS = 4;
	private final static int INICIA_FULLADS = 5;

	public RequestHandler(AdView adView, InterstitialAd interstitial) {
		this.adV = adView;
		RequestHandler.interstitial = interstitial;
	}
	
	protected static Handler handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			switch (msg.what) {
				case SHOW_ADS: {
					System.out.println("Mostando Banner");
	//				adV.setVisibility(View.VISIBLE);
					break;
				}case HIDE_ADS: {
	//				adV.setVisibility(View.GONE);
					System.out.println("Ocultando Banner");
					break;
				}case SHOW_FULLADS: {
	//				fadV.setVisibility(View.VISIBLE);
					System.out.println("Mostrando Anuncio completo");
					Adds.displayInterstitial();
//					if (interstitial.isLoaded()) {
//						interstitial.show();
//					}
					break;
				}case HIDE_FULLADS: {
	//				fadV.setVisibility(View.GONE);
					break;
				}case INICIA_FULLADS: {
					System.out.println("Iniciando Anuncio completo");
					Adds.iniciarInterstitial();
				}
			}
		}
	};

	@Override
	public void mostrarBanner(boolean show) {
		// TODO Auto-generated method stub
		handler.sendEmptyMessage(show ? SHOW_ADS : HIDE_ADS);
	}

	@Override
	public void mostrarAnuncioCompleto(boolean show) {
		// TODO Auto-generated method stub
		handler.sendEmptyMessage(show ? SHOW_FULLADS : HIDE_FULLADS);
	}

	@Override
	public void iniciarAnuncioCompleto() {
		// TODO Auto-generated method stub
		handler.sendEmptyMessage(INICIA_FULLADS);
	}
}